﻿using System;
using theeg.DependencyAnalysis.CommonAddin.Models;

namespace theeg.DependencyAnalysis.SdAddin
{
    public class SdProject : IProject
    {
        private readonly ICSharpCode.SharpDevelop.Project.IProject _sdProject;

        public string Name { get; set; }

        public bool IsSelected { get; set; }
        public string OutputFileName { get { return GetAssemblyPath(_sdProject); } }

        public SdProject(ICSharpCode.SharpDevelop.Project.IProject project)
        {
            _sdProject = project;
        }

        public static bool IsClrProject(ICSharpCode.SharpDevelop.Project.IProject project)
        {
            return !string.IsNullOrWhiteSpace(project.Language);
        }

        static string GetAssemblyPath(ICSharpCode.SharpDevelop.Project.IProject project)
        {
            try
            {
                return project.OutputAssemblyFullPath;
            }
            catch (Exception)
            {
                return string.Empty;
            }
        }
    }
}
